import createjs from "createjs-ts";
import cjs=createjs
import { createStage } from "./CreateJSHelper";
import { GameConfig, ScaleMode } from './Const';
const canvas=document.getElementById('GameCanvas') as HTMLCanvasElement
const gameDiv=document.getElementById('GameDiv') as HTMLDivElement
const onresize=(e?:Event)=>{
    console.log(gameDiv.clientWidth,gameDiv.clientHeight)
    switch (GameConfig.scaleMode) {
        case ScaleMode.FIT_WIDTH:
            GameConfig.pixelRatio=GameConfig.designWidth/gameDiv.clientWidth
            canvas.width=GameConfig.designWidth
            canvas.height=gameDiv.clientHeight*GameConfig.pixelRatio
            break;
        case ScaleMode.FIT_HEIGHT:
            GameConfig.pixelRatio=GameConfig.designHeight/gameDiv.clientHeight
            canvas.width=gameDiv.clientWidth*GameConfig.pixelRatio
            canvas.height=GameConfig.designHeight
            break;
        default:
            break;
    }
}
window.addEventListener('resize',onresize)
onresize()
//const stage=createStage(canvas,60,true,false)
//stage.addChild(new cjs.Bitmap('./assets/images/0.png'))

console.log('start')
const loader = new cjs.LoadQueue(false)
loader.addEventListener("complete", ()=>{
    console.log('加载完成')
})
loader.loadManifest([
    {src:'./assets/images/0.png',id:'loopbg'}
])